<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul>
        <li name="java">学习java</li>
        <li name="web">学习web</li>
        <li name="ui">学习ui</li>
    </ul>
</body>
<script>
    let lis = document.querySelectorAll('li')
    // let map = new Map()
    for (let i = 0; i < lis.length; i++) {
        lis[i].onclick = function () {
            alert(lis[i].getAttribute('name'));
        }
    }

</script>

</html>